(*# call(o_a_copy => off) *)
(*%F _fdata *)
(*# call(seg_name => null) *)
(*%E *)
(*# module(implementation=>on) *)
(*# data(seg_name => null) *)
DEFINITION MODULE QCcomm;

                     (* This JPI Modula-2 module is part of *)

                      (* QC -- a communications program *)
                             (* by Carl Neiburger *)
                              (* 169 N. 25th St.*)
                          (* San Jose, Calif. 95116 *)

                         (* CompuServe No. 72336,2257 *)

FROM NFIO IMPORT File, PathStr;
FROM UTIL IMPORT str3, str4, str5;
FROM QCdisp IMPORT ProtoType, MaskType;
FROM Str IMPORT CHARSET;

TYPE
    MaskNameArray = ARRAY MaskType OF str5;
    OnOffArray = ARRAY BOOLEAN OF str3;

CONST
    nul   = 00H;   soh   =  01;   stx   = 02H;   etx   =  03H;
    eot   = 04H;   enq   =  05;   ack   = 06H;   bs    =  10C;
    tab   = 09H;   lf    = 12C;   cr    = 15C;   dle   =  10H;
    xon   = 11H;   xoff  = 13H;   nak   = 15H;   syn   =  16H;
    can   = 18H;   ctlx  = 18H;   sub   = 1AH;   esc   =  33B;
    space = ' ';   cee   = 43H;   del   = 7FH;  

    ComTimedOut = 0FFFEH;
    ComNoCarrier = 0FFFDH;
    ComAbort = 0FFFCH;

    BuffSize = 8192;
    databits = 8;
    stopbits = 1;
    parity = 3;

    ProgramName = 'QC';  (* for transfer protocol IDs *)

CharSetNames = MaskNameArray ('7-bit', '8-bit', 'IBM  ');

OnOffNames = OnOffArray ('OFF', 'ON ');

BSDelNames = OnOffArray ('BS ', 'Del');

EscIResponse = '#DRB,QC2.3,CA,SS7o,GF,GH,GM,PB,PX,PY,PK';
             (*  Mod Ver VT100,24*80,Gif,HiRes,MedRes,
                             B-Prot,Xmodem,Ymodem,Kermit *)
             (* 132 lines : '#XXX,QC2.3,CA,SS7' + 242C + ',PB,PX' *)

VAR
    BackSpaceChars : CHARSET;

PROCEDURE CommWrData(ch : BYTE);

PROCEDURE CommWrStr( s : ARRAY OF CHAR ): CARDINAL;
(* returns checksum *)

PROCEDURE CommRdData(waitTime:CARDINAL ) : CARDINAL;
(* only tests for abort if data is not waiting *)

PROCEDURE CommRdDataTest(waitTime:CARDINAL ) : CARDINAL;
(* always tests for abort before checking for data *)

PROCEDURE setXon( TransmitOn, ReceiveOn : BOOLEAN);

(*#save *)
(*#call(near_call=>on) *)
PROCEDURE SetBaud(baud: SHORTCARD); 

PROCEDURE SetBS;
(* Sets BackSpaceCharacters *)

PROCEDURE SetUp(Init: BOOLEAN);

PROCEDURE checkAbort (): BOOLEAN;
(* USES CONTROL-INTERRUPT *)
(*#restore *)

END QCcomm.

